package org.example.admin.entity;

import java.io.Serial;
import java.io.Serializable;

import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Null;
import lombok.Data;
import org.example.core.valid.annontation.ListValue;
import org.example.core.valid.annontation.TypeValue;
import org.example.core.valid.group.AddGroup;
import org.example.core.valid.group.UpdateGroup;

/**
 * @author 小杰_cc
 * @version 1.0
 */
@Data
public class MenuEntity implements Serializable {
	@Serial
	private static final long serialVersionUID = 1L;

	@NotNull(message = "修改时必须指定id",groups = {UpdateGroup.class})
	@Null(message = "添加时不能指定id",groups = {AddGroup.class})
	private Long id;

	@NotNull(message = "父级菜单不能为空",groups = {UpdateGroup.class,AddGroup.class})
	private Long pid;

	@NotBlank(message = "菜单名不能为空",groups = {UpdateGroup.class, AddGroup.class})
	private String name;

	@NotBlank(message = "菜单类型不能为空",groups = {UpdateGroup.class, AddGroup.class})
	@TypeValue(value = {"M","C","B"}, message = "菜单类型错误",groups = {UpdateGroup.class, AddGroup.class})
	private String type;

	@NotNull(message = "排序字段不能为空",groups = {AddGroup.class, UpdateGroup.class})
	@Min(value = 0,message = "排序字段必须是一个大于等于0的数",groups = {UpdateGroup.class, AddGroup.class})
	private Integer sort;

	private String permission;

	private String path;

	private String component;

	private String icon;
	/**
	 * 状态(1:禁止,0:正常)
	 */
	@NotNull(message = "菜单状态不能为空",groups = {UpdateGroup.class, AddGroup.class})
	@ListValue(value = {0,1}, message = "菜单状态类型错误",groups = {UpdateGroup.class, AddGroup.class})
	private Integer status;
	/**
	 * 是否显示在左侧菜单栏(0-显示，1-不显示)
	 */
	@NotNull(message = "菜单是否显示字段不能为空",groups = {UpdateGroup.class, AddGroup.class})
	@ListValue(value = {0,1}, message = "菜单是否显示字段类型错误",groups = {UpdateGroup.class, AddGroup.class})
	private Integer visible;

	private Long createUser;

	private Long updateUser;

}
